package com.example.tnot.Teacher.CoursePart.CourseInternal.CourseDetailHome.Statistics.ClockIn.Adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.tnot.R;
import com.example.tnot.Teacher.CoursePart.CourseInternal.CourseDetailHome.Statistics.ClockIn.ItemBean.InternalClockIn;

import java.util.List;

public class rv_ClockInInternalAdapter extends RecyclerView.Adapter<rv_ClockInInternalAdapter.ViewHolder> {
    private List<InternalClockIn> data;
    public rv_ClockInInternalAdapter(List<InternalClockIn> data) {
        this.data = data;
    }
    @NonNull
    @Override
    public rv_ClockInInternalAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.item_rv_lock_in_internal_fragemnt, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull rv_ClockInInternalAdapter.ViewHolder holder, int position) {
        holder.tv_ClockInType.setText(data.get(position).getClockInType());
        holder.tv_time.setText(data.get(position).getTime());
        holder.iv_isToday.setImageResource(R.drawable.icon_clock_dot2);
        //添加判断,当时间为今天时,将图标改为实心
        if (holder.tv_time.getText() == "今天"){
            holder.iv_isToday.setImageResource(R.drawable.icon_clock_dot1);
        }

    }

    @Override
    public int getItemCount() {
        return data.size();
    }

    public static class ViewHolder extends RecyclerView.ViewHolder{
        ImageView iv_isToday;
        TextView tv_ClockInType,tv_time;
        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            iv_isToday = itemView.findViewById(R.id.iv_isToday);
            tv_ClockInType = itemView.findViewById(R.id.tv_ClockInType);
            tv_time = itemView.findViewById(R.id.tv_time);
        }

    }
}
